#ifndef __MESSAGE_SERVICE_H__
#define __MESSAGE_SERVICE_H__

#include <vector>
#include <map>
#include "Define.h"

class MessageServer{
private:
	struct _Subscriber
	{
		FWobject Reciever;
		void(*CallBack)(const FWobject sender, FWobject extra);
	};
	struct _Publisher
	{
		FWuint Tag;
		FWobject Sender;
		FWobject Extra;
	};
private:
	std::map<FWuint, std::vector<_Subscriber>> m_lstSubscribers;
public:
	static MessageServer* Instance;
private:
	MessageServer();	
	void ExecuteTag(_Publisher);
public:
	~MessageServer();

	static void Alloc();
	static void Malloc();
	void Clear();

	void Register(FWobject reciever, FWuint tag, void (*callBack)(const FWobject, FWobject));
	void Send(const FWobject sender, FWuint tag, FWobject extra);
};

#endif